<?php
namespace app\flash\controller;
use think\Controller;
use Alipay\aop\AopClient;
use Alipay\aop\request\AlipayTradeAppPayRequest;
class Alipay extends Controller
{
    public function huidiao(){
        echo 123;
    }
    // 支付宝支付
    public function BeforeAliPay(){
    //     Loader::import('../extend/AliPay/aop/AopClient.php');
    //     Loader::import('../extend/AliPay/aop/request/AlipayTradeAppPayRequest.php');
        $aop = new AopClient();
        // $request = new AlipayTradeAppPayRequest();
        // 沙箱
        $aop->gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
        $aop->appId = "2016091700533705";  //APPID
        // 正常
        // $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
        // $aop->appId = "2018*****3169";  // APPID
        $aop->rsaPrivateKey = 'MIIEpAIBAAKCAQEAvaIkEP6yT3GE3Dp2bwZN8LzZNPPDHGpujIJCgwcco+T9xm4xCVbNzPxK5sgNyyMMiJuF6SxOxPEEomYqa5zaPcguTeQk1Lc276C1wvWJFd6fK8MWUCigjQZ2PcKvAVjHdSWOPIVOQIa/xLRt+1qP5QE0kM4EVAWIKy6Pfvz/kFM13x2kCpsJf+MM1+WXCZcZsT5+TFXVUCRD0eQCqhfbXEtiurxDun244M9DNXGR3RGkXeJ+VF1L+x86CXUVRCTRU7zzxcCKW0RCP9uRG32QzJgE+jUDa8Y0HIkeR/UrRWsufTj0OALJ3yUt2GfMtTpdDh8SDgWNynNYRjV5t7Mk0QIDAQABAoIBABvQCBImCOj18VKLkItAFXZVfFXz2o30XjplcHPfOygekcnkp3SDMrP53NJ0TPGaNmBizwUf5n2kC9X1vgsCek/NaF0sNOqt5HTI0V/Cu1RlzlqQxlkDXGjSpczxHNHJv5dC5tWhh5SXLtEe1XKkGa6wupDyZlgcZ5hNv+YUHTeBfCIcjfgYRY0z9W3BGj4IxzhfkeDjM2FxitjW67OvM9YAoxiUICwwiGIW8PgHo4mc1hiLtHrME+49UA0odi4XWTSE/mRXmMzDUn2QXbhagnyTwCU1fOnH9+H2IBbkh+A6KFFrhNUlHGYBPV+EU02AC2l7y1elQZdr51rXEGsI8rECgYEA4h7cy4ErdoAzfyJTMa8Y+RH+kD32hjPu9KZ+bvj318D0Vq4CM4M3KdIW+AibK8NkqPrNQ17W3ueFDl7726vZbLRp4Xm0DL2QnrOvTnlkDIwv2mjIwDE2NaGev7/NWwMNYvZ4AL41Vomu7SnRCV2KcgFCP9cV9FYWWMGn6BDqfYcCgYEA1rEALYiGHY9AsEl6vt1Xh2VvK7oTV+9wiL2exV+n9q8khVvm5NkwEKOQsDJBKCvGxVZ2yaW3dyKyZjGLWnIdY6rFhHckUuLx+xgwOJmSJLch1b3pEDf7cSpSnGaUuTpSfOp5Max18gaVYIPuJucZQWiApc4XTbDw5jI+pbr9IOcCgYEAhrgoiD6vLGz5QXer5WATGuHzrvCb3h028x/3GBrRXwQhDzuhKBu3U/1Nnf1SpeJGKL80aD0q+6coiQViPODIK5HZu3KNKUIP1d3sRm7ggvFK2W+wm4E2cQGX2Vpm+SB6a0m4+YhZsvNY+wf8+P14LLA/TlXRSL+5lKvcY9EgRCUCgYAS7L1YRi2UU3lfUMraIkbB76YSE6/602d3Fkf1nA4BR8UPYF+FEsQS42gwr+1gbiNyZ8HG2q3Gea+CJKHlEiQXEgmhOKNiDxFHkgVGJ/ti8yWvYrM1s8mdWx63HK/FeCenTT/rqgknkX7/aAHJOhvW0TBt7THOrmc903YEQ+xmRwKBgQCZc/4/1iWapF/e+nI5WtmWBBVnH/Mknfboj1lkY+O6GVNhNRsl2mwbp7Xq2o8D1kwx27NiyHiJBOaN+O8a5WnnXP9M2l9L81czNRtDMCJAqy8jUeT3S6N/fqgGwCGezSNh1z0DuUn4K+1p2Yubp9mqHzYwXf8COunHS3SIWf+Rrw==';  //私钥
        $aop->format = "json";
        $aop->charset = "UTF-8";
        $aop->signType = "RSA2";
        $aop->alipayrsaPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvaIkEP6yT3GE3Dp2bwZN8LzZNPPDHGpujIJCgwcco+T9xm4xCVbNzPxK5sgNyyMMiJuF6SxOxPEEomYqa5zaPcguTeQk1Lc276C1wvWJFd6fK8MWUCigjQZ2PcKvAVjHdSWOPIVOQIa/xLRt+1qP5QE0kM4EVAWIKy6Pfvz/kFM13x2kCpsJf+MM1+WXCZcZsT5+TFXVUCRD0eQCqhfbXEtiurxDun244M9DNXGR3RGkXeJ+VF1L+x86CXUVRCTRU7zzxcCKW0RCP9uRG32QzJgE+jUDa8Y0HIkeR/UrRWsufTj0OALJ3yUt2GfMtTpdDh8SDgWNynNYRjV5t7Mk0QIDAQAB'; //公钥
        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称：alipay.trade.app.pay
        $request = new AlipayTradeAppPayRequest();
    }
    // 支付宝回调
    public function alipayVerfy(){
        require_once('../extend/AliPay/aop/AopClient.php');
        $aop = new \AopClient();
        $aop->alipayrsaPublicKey = '****';  //公钥
        $ret = $_POST;
        //订单产生的时间
        $gmt_create = $ret['gmt_create'];
        //商家账号
        $seller_email = $ret['seller_email'];
        //订单标题
        $subject = $ret['subject'];
        //卖家ID/买家支付宝用户号
        $buyer_id = $ret['buyer_id'];
        //支付金额
        $buyer_pay_amount = $ret['buyer_pay_amount'];
        //支付状态
        $trade_status = $ret['trade_status'];
        //订单号
        $out_trade_no = $ret['out_trade_no'];
        //订单备注
        $body = $ret['body'];

///下面做自己的参数处理，大概就是支付宝告诉你是否成功了，还携带了一些参数，具体可以打印$ret查看。然后根据自己的业务逻辑将这些参数处理，并是否写入数据库。

    }
}
